SHMGET

Section: System Calls (2)
Index Return to Main Contents

BSD mandoc
NetBSD  

NAME

shmget - get shared memory area identifier  

SYNOPSIS

Fd #include <sys/types.h> Fd #include <sys/ipc.h> Fd #include <sys/shm.h> Ft int Fn shmget key_t key int size int shmflg  

DESCRIPTION

Fn shmget returns the shared memory identifier associated with the key Fa key .

A shared memory segment is created if either Fa key is equal to IPC_PRIVATE, or Fa key does not have a shared memory segment identifier associated with it, and the IPC_CREAT bit is set in Fa shmflg.

If a new shared memory segment is created, the data structure associated with it (the shmid_ds structure, see shmctl(2)) is initialized as follows:

 

RETURN VALUES

Upon successful completion a positive shared memory segment identifier is returned. Otherwise, -1 is returned and the global variable errno is set to indicate the error.  

ERRORS

Bq Er EACESS
A shared memory segment is already associated with Fa key and the caller has no permission to access it.
Bq Er EEXIST
Both IPC_CREAT and IPC_EXCL are set in Fa shmflg , and a shared memory segment is already associated with Fa key .
Bq Er ENOSPC
A new shared memory indentifier could not be created because the system limit for the number of shared memory identifiers has been reached.
Bq Er ENOENT
IPC_CREAT was not set in Fa shmflg and no shared memory segment associated with Fa key was found.
Bq Er ENOMEM
There is not enough memory left to created a shared memory segment of the requested size.

 

SEE ALSO

shmctl(2), shmat(2), shmdt(2)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUES
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 16:28:59 GMT, April 18, 2022